package com.axjy.util;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;

@Data
public class Result {

    private String msg;
    private String code;
    private Long count;
    private Object data;

    public static Result success(Object data){
        Result result=new Result();
        result.code="0";
        result.data=data;
        return result;
    }

    public static Result success(Object data,Long count){
        Result result=new Result();
        result.code="0";
        result.count=count;
        result.data=data;
        return result;
    }

    public static Result success(IPage iPage){
        Result result=new Result();
        result.code="0";
        result.count=iPage.getTotal();
        result.data=iPage.getRecords();
        return result;
    }

    public static Result fail(String msg){
        Result result=new Result();
        result.code="500";
        result.msg=msg;
        return result;
    }

    public static Result success(String msg){
        Result result=new Result();
        result.code="1";
        result.msg=msg;
        return result;
    }



}
